package com.ruoyi.omp.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.omp.api.RemoteInspectionService;
import com.ruoyi.omp.api.domain.AfElevator;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 租赁记录降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteInspectionFactory implements FallbackFactory<RemoteInspectionService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteInspectionFactory.class);

    @Override
    public RemoteInspectionService create(Throwable throwable) {
        log.error("年检服务:{}", throwable.getMessage());
        return new RemoteInspectionService() {
            @Override
            public R<List<AfElevator>> listAfE(AfElevator afElevator) {
                return R.fail("电梯列表查询失败:" + throwable.getMessage());
            }

            @Override
            public R updateAfElevator(AfElevator afElevator) {
                return R.fail("电梯信息更新:" + throwable.getMessage());
            }

            @Override
            public R syncInfo(String queryDate) {
                return R.fail("电梯历史数据同步失败:" + throwable.getMessage());
            }
        };


    }
}
